Imports MySql.Data.MySqlClient
Public Class frmset_bl
    Dim mysql As MySqlConnection = main_form.mysqlconection
    Dim mySqlCommand As New MySqlCommand
    Dim mySqlAdaptor As New MySqlDataAdapter
    Dim mySqlReader As MySqlDataReader
    Public Shared idbooking As String
    Public Shared invoice As String
    Public Shared invoice1 As String

    Public Shared nm As String
    Public Shared mark As String
    Public Shared page1 As String
    Public Shared checkinv As String
    Public Shared datetimebl As String
    Public Shared textmsg As String

    Public Shared meastext As String
    Public Shared meast As String

    Private Sub frmset_bl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture

        mysql.Close()

        If mysql.State = ConnectionState.Closed Then
            mysql.Open()
        End If


        If mysql.State = ConnectionState.Closed Then
            mysql.Open()
        End If
        mySqlCommand.CommandText = "Select * from booking left join booking_bl on booking_bl.idbooking_bl =  booking.BINV   where BVOYAGE ='" & frmsearch_voyage1.idvoyage & "'  order by  BCTNTYPE ASC ,BFORWARDERNAME ASC;"
        ' mySqlCommand.CommandText = 
        mySqlCommand.Connection = mysql
        mySqlAdaptor.SelectCommand = mySqlCommand

        Try
            mySqlReader = mySqlCommand.ExecuteReader
            ListView2.Items.Clear()
            While (mySqlReader.Read())


                With ListView2.Items.Add(mySqlReader("BNO"))


                    If mySqlReader("BSHIPNAME") Is DBNull.Value Then
                        .SubItems.Add("-")
                    Else

                        .SubItems.Add(mySqlReader("BSHIPNAME"))
                    End If

                    If mySqlReader("BFORWARDERNAME") Is DBNull.Value Then
                        .SubItems.Add(mySqlReader("BFORWARDERNAME"))
                    Else

                        .SubItems.Add(mySqlReader("BFORWARDERNAME"))
                    End If

                    If mySqlReader("BCONFIRMDAY") Is DBNull.Value And mySqlReader("BCONFIRMTIME") Is DBNull.Value Then
                        .SubItems.Add("-")
                    Else

                        .SubItems.Add(mySqlReader("BCONFIRMDAY") + " @" + mySqlReader("BCONFIRMTIME"))
                    End If
                    .SubItems.Add(mySqlReader("BCTNNO") + " X " + mySqlReader("BCTNTYPE"))
                    .SubItems.Add(mySqlReader("BOOKINGID"))

                    .SubItems.Add(mySqlReader("BINV"))
                    If mySqlReader("billbooking") Is DBNull.Value Then
                    Else
                        .SubItems.Add(mySqlReader("billbooking"))
                    End If

                    'MsgBox(stringDate(0) + stringDate(1) + stringDate(2))


                End With



            End While


        Catch ex As Exception
            'MsgBox(ex.ToString)
        End Try
        mysql.Close()








    End Sub



    Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
        checkfill()

        Dim nextform As frmrpt_bl = New frmrpt_bl
        nextform.Show()




    End Sub
    Public Sub checkfill()

        If RadioButton1.Checked = True Then
            nm = "0"
        ElseIf RadioButton9.Checked = True Then
            nm = "2"
        Else
            nm = "1"
        End If

        If RadioButton3.Checked = True Then
            mark = "0"
        Else
            mark = "1"
        End If

        If RadioButton5.Checked = True Then
            page1 = "0"
        Else
            page1 = "1"
        End If

        If RadioButton7.Checked = True Then
            checkinv = "0"

        Else
            checkinv = "1"
        End If


        If RadioButton10.Checked = True Then
            meast = "0"
        Else
            meast = "1"
            meastext = TextBoxX1.Text
        End If
        datetimebl = DateTimeInput1.Text
        textmsg = TextBox1.Text
    End Sub

    Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click

        checkfill()

        Dim nextform As frmrpt_bl1 = New frmrpt_bl1
        nextform.Show()
 


    End Sub

    Private Sub ListView2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView2.Click
        invoice = Trim(ListView2.SelectedItems(0).SubItems(6).Text)


        idbooking = Trim(ListView2.SelectedItems(0).SubItems(5).Text)
    End Sub
End Class